package com.sailfish.springbootdemo.dao.db4;

import com.sailfish.springbootdemo.common.DB4TableName;
import com.sailfish.springbootdemo.pojo.db4.ApproveH3c;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface ApproveH3cDao {
    /**
     * 查询所有
     *
     * @return
     */
    @Results(id = "approveH3cResultMap", value = {
            @Result(column = "SUBJECT", property = "subject", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ADDUSERID", property = "adduserid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ADDUSERNAME", property = "addusername", jdbcType = JdbcType.VARCHAR),
            @Result(column = "APPLYTIME", property = "applytime", jdbcType = JdbcType.VARCHAR),
            @Result(column = "AUTHORID", property = "authorid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "AUTHORNAME", property = "authorname", jdbcType = JdbcType.VARCHAR),
            @Result(column = "URL", property = "url", jdbcType = JdbcType.VARCHAR),
            @Result(column = "SYSTEMID", property = "systemid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "APPID", property = "appid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "PROCESSID", property = "processid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "PROCESSNAME", property = "processname", jdbcType = JdbcType.VARCHAR),
            @Result(column = "DOCUNID", property = "docunid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "STATUS", property = "status", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ENDUSERID", property = "enduserid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ASSIGNER", property = "assigner", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NODEID", property = "nodeid", jdbcType = JdbcType.VARCHAR),
            @Result(column = "NODENAME", property = "nodename", jdbcType = JdbcType.VARCHAR),
            @Result(column = "TIMESTAMP", property = "timestamp", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ACCEPTTYPE", property = "accepttype", jdbcType = JdbcType.VARCHAR),
            @Result(column = "REDIRECTURL", property = "redirecturl", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ISBATCH", property = "isbatch", jdbcType = JdbcType.VARCHAR),
            @Result(column = "TODOPCURL", property = "todopcurl", jdbcType = JdbcType.VARCHAR),
            @Result(column = "ISPCDETAIL", property = "ispcdetail", jdbcType = JdbcType.VARCHAR),
            @Result(column = "BUTTONVALUE", property = "buttonvalue", jdbcType = JdbcType.VARCHAR),
            @Result(column = "LANGUAGEENV", property = "languageenv", jdbcType = JdbcType.VARCHAR),
            @Result(column = "USERNODEINFO", property = "usernodeinfo", jdbcType = JdbcType.VARCHAR),
    })
    @Select("<script>select * from " + DB4TableName.APPROVE_H3C
            + "<where> " +
            "<if test='systemid != null and systemid != \"\" '>" +
            " and SYSTEMID = #{systemid}" +
            "</if>" +
            "<if test='processid != null and processid != \"\" '>" +
            " and PROCESSID = #{processid}" +
            "</if>" +
            "<if test='docunid != null and docunid != \"\" '>" +
            " and DOCUNID = #{docunid}" +
            "</if>" +
            "</where>" +
            "</script>")
    ApproveH3c getById(@Param("systemid") String systemid, @Param("processid") String processid, @Param("docunid") String docunid);

    @Insert("insert into " + DB4TableName.APPROVE_H3C + "(SUBJECT, ADDUSERID, ADDUSERNAME, APPLYTIME, AUTHORID, AUTHORNAME, URL, SYSTEMID, APPID, PROCESSID, PROCESSNAME, DOCUNID, STATUS, ENDUSERID, ASSIGNER, NODEID, NODENAME, TIMESTAMP, ACCEPTTYPE, REDIRECTURL, ISBATCH, TODOPCURL, ISPCDETAIL, BUTTONVALUE, LANGUAGEENV, USERNODEINFO)" +
            "values (#{subject}, #{adduserid}, #{addusername}, #{applytime}, #{authorid}, #{authorname}, #{url}, #{systemid}, #{appid}, #{processid}, #{processname}, #{docunid}, #{status}, #{enduserid}, #{assigner}, #{nodeid}, #{nodename}, #{timestamp}, #{accepttype}, #{redirecturl}, #{isbatch}, #{todopcurl}, #{ispcdetail}, #{buttonvalue}, #{languageenv}, #{usernodeinfo})")
    Integer insert(ApproveH3c param);

    @Update("<script> " +
            "update " + DB4TableName.APPROVE_H3C +
            "<set>" +
            "<if test='subject != null and subject != \"\" '>" +
            " SUBJECT = #{subject}," +
            "</if>" +
            "<if test='adduserid != null and adduserid != \"\" '>" +
            " ADDUSERID = #{adduserid}," +
            "</if>" +
            "<if test='addusername != null and addusername != \"\" '>" +
            " ADDUSERNAME = #{addusername}," +
            "</if>" +
            "<if test='applytime != null and applytime != \"\" '>" +
            " APPLYTIME = #{applytime}," +
            "</if>" +
            "<if test='authorid != null and authorid != \"\" '>" +
            " AUTHORID = #{authorid}," +
            "</if>" +
            "<if test='authorname != null and authorname != \"\" '>" +
            " AUTHORNAME = #{authorname}," +
            "</if>" +
            "<if test='url != null and url != \"\" '>" +
            " url = #{url}," +
            "</if>" +
            "<if test='systemid != null and systemid != \"\" '>" +
            " systemid = #{systemid}," +
            "</if>" +
            "<if test='appid != null and appid != \"\" '>" +
            " appid = #{appid}," +
            "</if>" +
            "<if test='processid != null and processid != \"\" '>" +
            " processid = #{processid}," +
            "</if>" +
            "<if test='processname != null and processname != \"\" '>" +
            " processname = #{processname}," +
            "</if>" +
            "<if test='docunid != null and docunid != \"\" '>" +
            " DOCUNID = #{docunid}," +
            "</if>" +
            "<if test='status != null and status != \"\" '>" +
            " status = #{status}," +
            "</if>" +
            "<if test='enduserid != null and enduserid != \"\" '>" +
            " enduserid = #{enduserid}," +
            "</if>" +
            "<if test='assigner != null and assigner != \"\" '>" +
            " assigner = #{assigner}," +
            "</if>" +
            "<if test='nodeid != null and nodeid != \"\" '>" +
            " nodeid = #{nodeid}," +
            "</if>" +
            "<if test='nodename != null and nodename != \"\" '>" +
            " nodename = #{nodename}," +
            "</if>" +
            "<if test='timestamp != null and timestamp != \"\" '>" +
            " timestamp = #{timestamp}," +
            "</if>" +
            "<if test='accepttype != null and accepttype != \"\" '>" +
            " accepttype = #{accepttype}," +
            "</if>" +
            "<if test='redirecturl != null and redirecturl != \"\" '>" +
            " redirecturl = #{redirecturl}," +
            "</if>" +
            "<if test='isbatch != null and isbatch != \"\" '>" +
            " isbatch = #{isbatch}," +
            "</if>" +
            "<if test='todopcurl != null and todopcurl != \"\" '>" +
            " todopcurl = #{todopcurl}," +
            "</if>" +
            "<if test='ispcdetail != null and ispcdetail != \"\" '>" +
            " ispcdetail = #{ispcdetail}," +
            "</if>" +
            "<if test='buttonvalue != null and buttonvalue != \"\" '>" +
            " buttonvalue = #{buttonvalue}," +
            "</if>" +
            "<if test='languageenv != null and languageenv != \"\" '>" +
            " languageenv = #{languageenv}," +
            "</if>" +
            "<if test='usernodeinfo != null and usernodeinfo != \"\" '>" +
            " usernodeinfo = #{usernodeinfo}," +
            "</if>" +
            "</set>" +
            "where SYSTEMID = #{systemid} and PROCESSID = #{processid} and DOCUNID = #{docunid}" +
            "</script>")
    Integer update(ApproveH3c param);

    @Delete("<script>" +
            "delete from " + DB4TableName.APPROVE_H3C +
            "<where>" +
            "<if test='systemid != null and systemid != \"\" '>" +
            " and SYSTEMID = #{systemid}" +
            "</if>" +
            "<if test='processid != null and processid != \"\" '>" +
            " and PROCESSID = #{processid}" +
            "</if>" +
            "<if test='docunid != null and docunid != \"\" '>" +
            " and DOCUNID = #{docunid}" +
            "</if>" +
            "</where>" +
            "</script> ")
    Integer detele(@Param("systemid") String systemid, @Param("processid") String processid, @Param("docunid") String docunid);
}
